<template>
  <view class="form-item-time">
    <wd-input v-bind="$attrs" clearable v-model="localValue" readonly @click="onClick" />

    <VTimeInterval
      v-model:value="dateTimeValue"
      v-model:visible="visible"
      @update:value="onUpdateVal"
    />
  </view>
</template>

<script lang="ts" setup>
import VTimeInterval from '../Popup/TimeInterval.vue'
interface Props {
  value: any
}

const dateTimeValue = ref(undefined)
const visible = ref(false)

const props = withDefaults(defineProps<Props>(), {})

const emit = defineEmits<{
  'update:value': [value: string]
}>()
const localValue = computed({
  get: () => {
    return props.value
  },
  set: (val) => {
    emit('update:value', val)
  },
})

function onClick() {
  visible.value = true
}

const onUpdateVal = (val) => {
  console.log('当前行：', 41, '[ val ] ==>', val)
  emit('update:value', val.join(','))
}
</script>

<style lang="scss" scoped>
.form-item-time {
  text-align: right !important;
}
</style>
